/**
 * const baseUri = process.env.NODE_ENV === 'production' ? 'http://127.0.0.1:8099' : 'http://127.0.0.1:3000'
 * @vencano 如果开发未进行前后分离：可定义url 常量，然后，如：
 *  export const testApi = {
 *    testGetUrl: () => baseUri+'/getone',
 *    testPostUrl: id => baseUri+'/modified/'+id
 *  }
 */

const baseUri = process.env.NODE_ENV === 'production' ? '' : '/api'

/**
 * 文件上传加载接口
 */
export const commonApi = {
  // POST
  uploadFilesUrl:() => baseUri + '/files/upload',
  //POST 压缩大小
  uploadFilesUrlCompress:(width,height)=> baseUri + '/files/upload?width='+width+'&height='+height,
  // GET
  retrieveFileUrl: fileName => baseUri + '/files/retrieve/' + fileName
}

/**
 * 用户模块接口
 */
export const userApi = {
  // POST
  loginAuthUrl: () => baseUri + '/login',
  // GET
  loginOutUrl: () => baseUri + '/logout',
  // GET
  userInfoUrl: () => baseUri + '/users/info',
  // GET
  userDetailsUrl: () => baseUri + '/users/details',
  // PUT 修改用户信息
  updateDetailsUrl: userId => baseUri + '/users/' + userId,
  // PUT
  updatePasswordUrl: () => baseUri + '/users/update_pwd'
}

/**
 * 客户模块接口
 */
export const customerApi = {
  // POST
  addOneUrl: () => baseUri + '/customers',
  // PUT
  updateOneUrl: customerId => baseUri + '/customers/' + customerId,
  // GET
  getOneUrl: customerId => baseUri + '/customers/' + customerId,
  // GET
  getListUrl: params => !params ? baseUri + '/customers' : baseUri + '/customers' + params,
  // DELETE
  deleteOneUrl: customerId => baseUri + '/customers/' + customerId,
  // PUT 修改密码
  changePasswordUrl: customerId => baseUri + '/customers/' + customerId + '/change_pwd'
}

/**
 * 商品分类接口 /goo/item/cates
 */
const gooItemCateUri = '/goo/item/cates';

export const gooItemCateApi = {
  // POST
  addOneUrl: () => baseUri + gooItemCateUri,
  // PUT
  updateOneUrl: cateId => baseUri + gooItemCateUri + '/' + cateId,
  // GET
  getOneUrl: cateId => baseUri + gooItemCateUri + '/' + cateId,
  // GET
  getListUrl: () => baseUri + gooItemCateUri,
  // GET
  searchUrl: (keywords) => !keywords ? baseUri + gooItemCateUri + "/search" : baseUri + gooItemCateUri + '/search?keywords=' + keywords,
  // DELETE
  deleteOneUrl: cateId => baseUri + gooItemCateUri + '/' + cateId,
}
/**
 * 商品
 */
export const gooItemApi = {
  // POST
  addOneUrl: () => baseUri + "/goo/items",
  // PUT
  updateOneUrl: gooId => baseUri + '/goo/items/' + gooId,
  // PUT
  updateStatusUrl: (gooId, status) => !status ? baseUri + '/goo/items/' + gooId + '/status' : baseUri + '/goo/items/' + gooId + '/status?status=' + status,
  // PUT
  updateDescUrl: gooId => baseUri + '/goo/items/' + gooId + '/desc',
  // GET
  getOneUrl: gooId => baseUri + '/goo/items/' + gooId,
  // GET
  getListUrl: params => !params ? baseUri + '/goo/items' : baseUri + '/goo/items' + params,
  // DELETE
  deleteOneUrl: gooId => baseUri + '/goo/items/' + gooId,
}
/**控制面板 */
export const panelsApi = {
  //GET
  getActivesUrl: () => baseUri + '/control/actives',
  //GET
  getFuncsDateTypeUrl: datetype => baseUri + '/control/funcs/datetype?datetype=' + datetype,
  //GET
  getFuncsStartendUrl: (paramsStr) => baseUri + '/control/funcs/startend'+paramsStr,

}